package com.briup.njf;

import com.briup.corejava.chap13.bean.Student;

public class Test1_Method {
    public static void main(String[] args) {
        //先使用lambda
        Action1 a1 = ()->{};
        Action2 a2 = (a,b) -> a+b;
        Action3 a3 = ()->{return new Student();};
        Action4 a4 = l->{return new int[l];};
        // 使用方法引用
        // 静态方法引用 类名::方法名
        Action1 a6 = Test1_Method::test;
        // 非晶态方法引用 对象名::方法名字
        Test1_Method tm = new Test1_Method();
        Action1 a7 = tm::sayHello;
        // 类名::方法名
        // Action2 a8 = Test1_Method::sayHello; // 错误
        Action5 a8 = Test1_Method::sayHello;

        // 构造方法
        Action3 a9 = Student::new;

        // 数组构造
        Action4 a10 = int[]::new;
    }
    public static void test(){
        System.out.println("test");
    }
    public void sayHello(){
        System.out.println("hello");
    }
}

interface Action1{
    void run();
}
interface Action2{
    int run(int a, int b);
}
interface Action3{
    Student run(/*String id, String name, int age*/);
}
interface Action4{
    int[] run(int len);
}
interface Action5{
    void run(Test1_Method tm);
}
